<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    Function.prototype.uncurrying = function () {
        console.log(this);
        var self = this;
        return function() {
            console.log(arguments)
            var obj = Array.prototype.shift.call( arguments );
            console.log(obj)
            console.log(this)
            console.log(self)
            return self.apply( obj, arguments );
        };
    };
    var call = Function.prototype.call.uncurrying();
    var fn = function( name ){
        console.log( name );
    };
    call( fn, window, 'sven' ); // 输出：sven
    var apply = Function.prototype.apply.uncurrying();
    var fn = function( name ){
        console.log( this.name ); // 输出："sven"
        console.log( arguments ); // 输出: [1, 2, 3]
    };
    apply( fn, { name: 'sven' }, [ 1, 2, 3 ] );

/*Function.prototype.uncurrying = function () {
    var self = this; // self 此时是 Array.prototype.push
    return function() {
        var obj = Array.prototype.shift.call( arguments );
        // obj 是{
        // "length": 1,
        // "0": 1
        // }
        // arguments 对象的第一个元素被截去，剩下[2]
        return self.apply( obj, arguments );
        // 相当于 Array.prototype.push.apply( obj, 2 )
    };
};
    var push = Array.prototype.push.uncurrying();
    var obj = {
        "length": 1,
        "0": 1
    };
    push( obj, 2 );
    console.log( obj );*/
</script>

</body>
</html>